package view.macrogui 
{
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import model.macro.Building;
	
	/**
	 */
	public class BuildingListItem extends Sprite 
	{
		private const FORMAT:TextFormat = new TextFormat("Helvetica", 12, 0xFFFFFF);
		static public const HEIGHT:int = 64;
		static public const WIDTH:int = 64;
		
		private var building:Building;
		private var text_field:TextField;
		
		public function BuildingListItem() 
		{
			text_field = new TextField();
			text_field.defaultTextFormat = FORMAT;
			text_field.selectable = false;
			text_field.x = 1;
			text_field.y = -1;
			addChild(text_field);
			
			graphics.beginFill(0x555555);
			graphics.drawRoundRect(0, 0, WIDTH, HEIGHT, 8);
			graphics.endFill();
		}
		
		public function update(building:Building):void
		{
			this.building = building;
			text_field.text = "" + building.gold_per_turn;
			if (building.gold_per_turn > 0)
				text_field.textColor = 0x00FF00;
			else if (building.gold_per_turn < 0)
				text_field.textColor = 0xFF5555;
			else
				text_field.textColor = 0xDDDDDD;
		}
		
		private function redraw():void
		{
			if (building == null)
				return;
		}
		
	}

}